<%@page import="java.sql.ResultSet"%>
<%@page import="java.sql.Statement"%>
<%@page import="java.sql.DriverManager"%>
<%@page import="java.sql.Connection"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>观看视频|银光云-为银光字幕组提供最优质的云存储服务 - Powered by 金鸡独立</title>
<%
	String id=request.getParameter("id");
	Class.forName("com.mysql.jdbc.Driver");
	Connection con=DriverManager.getConnection((String) application.getAttribute("dburl"),(String) application.getAttribute("username"),(String) application.getAttribute("password"));
	Statement sm=con.createStatement();
	String sqls1="SELECT userid,name,datetime,detail,hidden,count,file FROM data WHERE id="+id;
	ResultSet rs1=sm.executeQuery(sqls1);
	if(rs1==null){
		out.print("致命错误-0004：无法在数据库中找到对应记录！有关解决方案，请联系QQ2276768747。");
		return ;
	}
	rs1.next();
	String userid=rs1.getString(1);
	String name=rs1.getString(2);
	String datetime=rs1.getString(3);
	String detail=rs1.getString(4);
	boolean hidden=rs1.getBoolean(5);
	int count=rs1.getInt(6);
	String filename=rs1.getString(7);
	String videopath=application.getAttribute("url")+"data/"+filename;
	String sqls2="SELECT name FROM user WHERE id="+userid;
	ResultSet rs2=sm.executeQuery(sqls2);
	if(rs2==null){
		out.print("致命错误-0005：无法在user数据库中找到对应用户名！有关解决方案，请联系QQ2276768747。");
		return ;
	}
	rs2.next();
	String username=rs2.getString(1);
	String download="/SilverCould/data/"+filename;//application.getAttribute("url")+"data/"+filename;
	String sqls3="UPDATE data SET count="+(++count)+" WHERE id="+id;
	sm.executeUpdate(sqls3);
%>
<!-- 自动刷新定义 
<meta http-equiv="refresh" content="0.1; url=watch.jsp?id=<%=id %>">
-->
</head>
<body>
<center>
<h1><font color="red">银光字幕组专属云-视频播放</font></h1>
<table>
	<tr>
		<td><a href="/SilverCould/index.jsp">返回主页</a></td>
		<td>
			<form action="/SilverCould/page/search.jsp" method="get">
				<input type="text" id="keyword" name="keyword" style="width: 350px">
				<input type="submit" value="搜索">
			</form>
		</td>
	</tr>
</table>
<%
	if(hidden==true){
		out.println("本记录hidden=true，无法提供播放服务，请联系发布者。");
		return ;
	}
%>
<br/>
视频信息表：
<table border="1">
	<tr>
		<td>标题：</td>
		<td><%=name %></td>
	</tr>
	<tr>
		<td>上传时间：</td>
		<td><%=datetime %></td>
	</tr>
	<tr>
		<td>简介：</td>
		<td><%=detail %></td>
	</tr>
	<tr>
		<td>上传者：</td>
		<td><%=username %></td>
	</tr>
	<tr>
		<td>访问人次</td>
		<td><%=count %></td>
	</tr>
	<tr>
		<td>下载链接：</td>
		<td><a href="download.jsp?id=<%=id %>">点击下载</a></td>
	</tr>
</table>
视频在线预览：<br/>
<video src=<%=download %> controls="controls" width="640" height="360">
</video>
</center>
</body>
</html>